﻿using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Web;

namespace WebApp
{
    public class Program
    {

        public static void Main(string[] args)
        {
            //NLogBuilder.ConfigureNLog("nlog.config");

            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureServices(service =>
                {
                })
                .ConfigureAppConfiguration(builder =>
                {
                })
                .UseStartup<Startup>()
                // 如需指定多个程序集时，使用 ; 分割
                .UseSetting(WebHostDefaults.HostingStartupAssembliesKey, "Repository")
                .ConfigureLogging((c, b) =>
                {
                    // 由于引用了NLog,可清空DotnetCore启动时注入的Proviers
                    b.ClearProviders();

                    // 由于引用了NLog,日志的级别交给NLog处理
                    b.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
                   
                })
                .UseNLog()
                .Build();
    }
}
